
package com.xinzhi.controller;

import com.xinzhi.pojo.User;
import com.xinzhi.pojo.dto.Usera;
import com.xinzhi.service.UserService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private  UserService userService;

    /**
     * 登录接口
     * @param account
     * @param password
     * @return
     */
    @GetMapping("/login")
    public Result login(String account, String password){
        return userService.login(account,password);
    }

    /**
     * 注册接口
     * @param user
     * @return
     */
    @PostMapping("/register")
    public Result register(@RequestBody User user){
        return userService.insertUser(user);
    }


    @GetMapping("/getUser")
    public List<Usera> getUser(){
        return  userService.getUsera();
    }
}